﻿/******************************************************************************
* File description: ControlPannelButton.qml
* Function: 实验控制按钮组件
* Current Version: 1.0.0
* Author: JNN
* Date: 2025-07-01
*  -----
*  Copyright by 博坤生物 .
 *****************************************************************************/
import QtQuick 2.0
import "../components"

Rectangle {

    id: root


    height: 82*dp
    width: text_title.x + text_title.implicitWidth + image.x

    property string icon: "qrc:/picture/controlPannelButton/run.png"
    property string icon_disabled: "qrc:/picture/controlPannelButton/run_d.png"
    property string title: "运行"
    property bool enabled: true
    property color fontColor:"#222"

    border.color: enabled ? "transparent" : "#11111111"

    radius: 12*dp

    signal clicked()
    signal clicked_disabled()

    property bool isHovered: false

    CustomImage{
        id: image
        source: root.enabled ? root.icon : root.icon_disabled
        height: 36*dp
        width: 36*dp
        anchors.verticalCenter: parent.verticalCenter
        x: 26*dp
    }
    Rectangle{      // 鼠标悬浮
        color: title==="运行" ? "#18000000" : "#11444444"
        anchors.fill: parent
        visible: isHovered && root.enabled
        radius: parent.radius
    }

    Text{
        id: text_title
        text: title
        anchors.verticalCenter: parent.verticalCenter
        x: 76*dp
        font.pixelSize: config.fontsize_1
        font.bold: true
        color: enabled ? fontColor: "#BBB"
    }
    Rectangle{  // 禁用遮挡
        color: "#11999999"
        visible: !root.enabled
        radius: root.radius
        anchors.fill: parent
    }


    MouseArea{
        anchors.fill: parent
        cursorShape: root.enabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
        hoverEnabled: true
        onEntered: {
            root.isHovered = true
        }onExited: {
            root.isHovered = false
        }
        onClicked: {
            if(root.enabled){
                root.clicked()
            }else{
                root.clicked_disabled()
            }

        }
    }



}
